$(document).ready(function() {
	
	$("#submit").click(login);

	$(document).keydown(function(){
		if(event.keyCode === 13){
			login();
		}
	});
});

function login(){
	var username = $("#name").val();
	var password = $("#password").val();
	$.ajax({
		url: 'php/interface.php?method=login',
		method: 'post',
		dataType: 'json',
		data: {
			username: username,
			password: password
		}
	}).done(function(data) {
		if (data.result === true) {
			location.href = 'admin/check.php';
		} else {
			alert(data.msg);
		}
	});
}
